/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author asall
 */
public class ListeEc {
    static Connexion con= new Connexion();
        public String libelle;
	public String minChoix;
	public String maxChoix;
	public ArrayList<Ec> ecs;
        
        public ListeEc(){}
        public ListeEc(String libelle, String minChoix, String maxChoix, ArrayList<Ec> ec){
	this.libelle=libelle;
	this.ecs=ec;
	this.minChoix=minChoix;
	this.maxChoix=maxChoix;

	}
   
  public static ListeEc getListeEc(int idUe) {
        Ec ec=new Ec();
        String libelle=" libelle ue";
	ArrayList<Ec> eC =ec.getEcs(1);
	String min= "0";
	String max="10";
	ListeEc el=new ListeEc(libelle,min, max,eC);
        

	try {
		Statement req = con.getInstance().createStatement();

                ResultSet resultatDest = req.executeQuery("select l.libelle_liste_ec, l.select_max,l.select_min,l.id_liste_ec"
                        + " from ue u, liste_ec l"
                        + " where l.fid_ue=u.id_ue and u.id_ue= "+ idUe );

        	while (resultatDest.next()) {
	         int idListeEc=(resultatDest.getInt("id_liste_ec"));
		 libelle=(resultatDest.getString("libelle_liste_ec"));	
		 min=(resultatDest.getString("select_min"));
		 max=(resultatDest.getString("select_min"));
		 eC=ec.getEcs(idListeEc);
		
		 el= new ListeEc(libelle,min,max,eC);
		
		}

		} 
	     catch (Exception e) {

			e.printStackTrace();
		}
          
	
       return el;
}
    
}
